package com.system.tree.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="t_tree")
public class Tree {
	private Long treeId;
	private String text;
	private String iconCls;
	private String viewType;
	private boolean leaf;
	private Long fatherId = null;
	private List<Tree> children = new ArrayList<Tree>();
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getTreeId() {
		return treeId;
	}
	public String getText() {
		return text;
	}
	public String getIconCls() {
		return iconCls;
	}
	public String getViewType() {
		return viewType;
	}
	public boolean isLeaf() {
		return leaf;
	}
	public Long getFatherId() {
		return fatherId;
	}
	@OneToMany(fetch=FetchType.EAGER)
	public List<Tree> getChildren() {
		return children;
	}
	public void setTreeId(Long treeId) {
		this.treeId = treeId;
	}
	public void setText(String text) {
		this.text = text;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	public void setViewType(String viewType) {
		this.viewType = viewType;
	}
	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
	public void setFatherId(Long fatherId) {
		this.fatherId = fatherId;
	}
	public void setChildren(List<Tree> children) {
		this.children = children;
	}
	@Override
	public String toString() {
		return "Tree [treeId=" + treeId + ", text=" + text + ", iconCls=" + iconCls + ", viewType=" + viewType
				+ ", leaf=" + leaf + ", fatherId=" + fatherId + ", children=" + children + "]";
	}
	
	
	
}
